package com.chengqj.factory.singlefactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @program: pattern
 * @description: 注册式
 * @author: chengqj
 * @create: 2018-08-06 18:41
 **/
public class Register {
    private Register() {
    }

    ;

    private static Map<String, Register> registerMap = new ConcurrentHashMap<>();

    public static Register getInstance(String name) {
        if (name == null) {
            name = Register.class.getName();
        }
        if (registerMap.get(name) == null) {
            registerMap.put(name, new Register());
        }
        return registerMap.get(name);
    }
}
